package com.hdf.etdemo.viewframe.fragment;

import com.hdf.easytools.view.tabmenu.PagerSlidingTabStrip;
import com.hdf.etdemo.R;
import com.hdf.etdemo.viewframe.SlidingtabActivity.MyAdapter;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class Page3 extends Fragment {
	PagerSlidingTabStrip tabs;
	ViewPager pager;
	DisplayMetrics dm;
	AFrag afrag;
	BFrag bfrag;
	CFrag cfrag;
	String[] titles = { "AA", "BB", "CC" };
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.page3_fragment, null);
		TextView title=(TextView) view.findViewById(R.id.center_text);
		title.setText("财富的标题");
		dm = getResources().getDisplayMetrics();
		pager = (ViewPager) view.findViewById(R.id.pager);
		tabs = (PagerSlidingTabStrip) view.findViewById(R.id.tabs);
		pager.setAdapter(new MyAdapter(getActivity().getSupportFragmentManager(), titles));
		tabs.setViewPager(pager);
		return view;
	}
	public class MyAdapter extends FragmentPagerAdapter {
		String[] _titles;

		public MyAdapter(FragmentManager fm, String[] titles) {
			super(fm);
			_titles = titles;
		}
		
		@Override
		public CharSequence getPageTitle(int position) {
			return _titles[position];
		}
		
		@Override
		public int getCount() {
			return _titles.length;
		}

		@Override
		public Fragment getItem(int position) {
			switch (position) {
			case 0:
				if (afrag == null) {
					afrag = new AFrag();
				}
				return afrag;
			case 1:
				if (bfrag == null) {
					bfrag = new BFrag();
				}
				return bfrag;
			case 2:
				if (cfrag == null) {
					cfrag = new CFrag();
				}
				return cfrag;
			default:
				return null;
			}
		}
	}

}
